<?php
/**
 * @copyright   七月
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      July<july491@163.com>
 * 后台登录
 */
namespace app\admin\Controller;
use think\Controller;
use app\common\controller\Admin;


class Regist extends Admin{
 
    /**
    * 登录
    */
       public function index()
    {
        if(request()->isPost())
        {
            $data = [
                'username'  => input('post.username/s'),
                'password'  => input('post.password/s'),
                'email'     => input('post.email/s')
            ];
            $validate = $this->validate($data,'Login.regist');
            if(true !== $validate)
            {
                return json(['code'=>0,'msg'=>$validate]);
            }
            $result  = model('JuSer')->updateUser($data);
            if($result)
            {
                $this->setLoginSession($result);
                return json(['code'=>200,'msg'=>'注册成功','url' => url('admin/index/index')]);
            }
        }else{
            return view(); 
        }
    }


}